package com.sinux.sshUser.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author WangGan
 * @version 2017年6月2日 上午9:45:52 
 * 
 */
public class PropertiesUtil {
	String k="rootDepartNumber";
	String p="main/resources/config.properties";
	FileInputStream inputFile;
	static PropertiesUtil ptu=new PropertiesUtil();
	//获取配置文件信息
	public static String rootDepartNumber(String key,String fileName){
		String rootNumber="135064";
		rootNumber = ptu.getProperties(key,fileName);
		return rootNumber;
	}
	//加载配置文件
	public String getProperties(String key,String fileName){
			
		Properties properties = new Properties();
		try {
			 inputFile = new FileInputStream(this.getClass().getClassLoader().getResource(fileName).getPath());
			properties.load(inputFile); //路径错误,is为空
			inputFile.close();
		} catch (FileNotFoundException ex) {  
            System.out.println("读取属性文件--->失败！- 原因：文件路径错误或者文件不存在");  
            ex.printStackTrace();  
        } catch (IOException ex) {  
            System.out.println("装载文件--->失败!");  
            ex.printStackTrace();  
        }
		return properties.getProperty(key);
		
	}

}
